// Diagonal.java

/*
 * 本类实现对角方式的方阵遍历。
 */
public class Diagonal extends SquareTraversal {
    public Diagonal(int size) {
        // 在这里添加代码：
        initiate(size);
    }

    @Override
    public SquarePoint getInitPoint() {
        // 在这里添加代码：
        //左下角起点
        return new SquarePoint(size - 1, 0);
    }

    @Override
    public SquarePoint getNext() {
        // 在这里添加代码：
        SquarePoint currentPoint = currentPath.get(currentPath.size() - 1);

        int currRow = currentPoint.getRow();
        int currCol = currentPoint.getCol();
        int nextRow = currRow;
        int nextCol = currCol;

        if(currCol == size - 1 && currRow == 0) {
            //右上角终点
            return null;
        }else if(currRow == size - 1 && currCol == size - 1) {
            //右下角特殊处理
            nextCol = 1;
            nextRow = 0;
        }else if(currRow == size - 1) {
            //最后一行
            nextCol = 0;
            nextRow = size - 1 - currCol -1;
        }else if(currCol == size - 1)
        { //最后一列
            nextCol = size - 1 - currRow + 1;
            nextRow = 0;
        }else{
            //一般情况
            nextCol = currCol + 1;
            nextRow = currRow + 1;
        }

        return new SquarePoint(nextRow, nextCol);
    }

    private int getStartingRow(int difference) {
        // 在这里添加代码：
        //？
        return 0;
    }
}